<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<!--[if IE 8]> <html lang="en" class="ie8"> <![endif]-->
<!--[if !IE]><!-->
<html lang="zh">
<!--<![endif]-->
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path;
%>

<head>
    <meta charset="utf-8"/>
    <%@include file="../common/taglib.jsp" %>
    <title>保险代理后台管理系统</title>
    <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" name="viewport"/>
    <meta content="" name="description"/>
    <meta content="" name="author"/>
    <!-- ================== BEGIN BASE CSS STYLE ================== -->
    <jsp:include page="../common/header.jsp"></jsp:include>
    <!-- ================== END BASE CSS STYLE ================== -->

    <!-- ================== 单独作用于本页表格td ================== -->
    <style>
        body {
            background: white;
        }


    </style>
    <!-- ================== 单独作用于本页表格td ================== -->
</head>
<body>
<section>
    <%-- <ul class="nav nav-pills">
         <li class="active"><a href="#tab1" data-toggle="tab">保单信息</a></li>
     </ul>--%>
    <jsp:useBean id="now" class="java.util.Date"></jsp:useBean>
    <div class="form-wrap mar-bottom-0">
        <div class="tab-content">
            <div id="tab1" class="tab-pane fade active in">
                <h4>投保客户信息</h4>
                <div class="form-horizontal">
                    <div class="form-group">
                        <label class="col-sm-2 control-label">保单号：</label>
                        <div class="col-sm-10">
                            <p class="form-control-static">${orderInfo.ordNum}</p>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">车主：</label>
                        <div class="col-sm-10">
                            <p class="form-control-static">${orderInfo.carOwner}</p>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">车牌号：</label>
                        <div class="col-sm-10">
                            <p class="form-control-static">${orderInfo.plateNum}</p>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">车架号：</label>
                        <div class="col-sm-10">
                            <p class="form-control-static">${orderInfo.engineNum}</p>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">车辆种类：</label>
                        <div class="col-sm-10">
                            <p class="form-control-static">
                                <c:choose>
                                    <c:when test="${orderInfo.vehicleType == 1}">客车</c:when>
                                    <c:when test="${orderInfo.vehicleType == 2}">货车</c:when>
                                </c:choose>
                            </p>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">被保险人：</label>
                        <div class="col-sm-10">
                            <p class="form-control-static">${orderInfo.insurant}</p>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">被保险人身份证号/<br>组织机构代码：</label>
                        <div class="col-sm-10">
                            <p class="form-control-static">${orderInfo.orgIdCode}</p>
                        </div>
                    </div>
                </div>
                <h4>保险信息</h4>
                <div class="form-horizontal">
                    <div class="form-group">
                        <label class="col-sm-2 control-label">保险公司：</label>
                        <div class="col-sm-10">
                            <p class="form-control-static">${orderInfo.insyrerName}</p>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">险种：</label>
                        <div class="col-sm-10">
                            <c:choose>
                                <c:when test="${orderInfo.typeInsurance==0}">
                                    <p class="form-control-static">交强险</p>
                                </c:when>
                                <c:when test="${orderInfo.typeInsurance==1}">
                                    <p class="form-control-static">商业险</p>
                                </c:when>
                            </c:choose>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">保单生效日期：</label>
                        <div class="col-sm-10">
                            <p class="form-control-static">${orderInfo.datePolicy}</p>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">垫资类型：</label>
                        <div class="col-sm-10">
                            <c:choose>
                                <c:when test="${orderInfo.typeInsurance2==1}">
                                    <p class="form-control-static">不垫资</p>
                                </c:when>
                                <c:when test="${orderInfo.typeInsurance2==2}">
                                    <p class="form-control-static">垫返点</p>
                                </c:when>
                                <c:when test="${orderInfo.typeInsurance2==3}">
                                    <p class="form-control-static">垫保费</p>
                                </c:when>
                            </c:choose>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">垫资账期：</label>
                        <div class="col-sm-10">
                            <p class="form-control-static">${orderInfo.laonAccount} 天</p>
                        </div>
                    </div>
                    <c:choose>
                        <c:when test="${orderInfo.typeInsurance==0 }">
                            <div class="form-group">
                                <label class="col-sm-2 control-label">交强险保费：</label>
                                <div class="col-sm-10">
                                    <p class="form-control-static">${orderInfo.pulsoryPremium}</p>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">车船税：</label>
                                <div class="col-sm-10">
                                    <p class="form-control-static">${orderInfo.vechcleVesselTax}</p>
                                </div>
                            </div>
                        </c:when>
                        <c:when test="${orderInfo.typeInsurance==1 }">
                            <div class="form-group">
                                <label class="col-sm-2 control-label">商业险保费：</label>
                                <div class="col-sm-10">
                                    <p class="form-control-static">${orderInfo.mercialPremium}</p>
                                </div>
                            </div>
                        </c:when>
                    </c:choose>
                    <c:choose>
                        <c:when test="${orderInfo.typeInsurance==0 }">
                            <div class="form-group">
                                <label class="col-sm-2 control-label">交强险跟单点位：</label>
                                <div class="col-sm-10">
                                    <p class="form-control-static">${orderInfo.followPoint}</p>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">交强险补单点位：</label>
                                <div class="col-sm-10">
                                    <p class="form-control-static">${orderInfo.replenishPoint}</p>
                                </div>
                            </div>
                        </c:when>
                        <c:when test="${orderInfo.typeInsurance==1 }">
                            <div class="form-group">
                                <label class="col-sm-2 control-label">商业险跟单点位：</label>
                                <div class="col-sm-10">
                                    <p class="form-control-static">${orderInfo.followPoint}</p>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">商业险补单点位：</label>
                                <div class="col-sm-10">
                                    <p class="form-control-static">${orderInfo.replenishPoint}</p>
                                </div>
                            </div>
                        </c:when>
                    </c:choose>
                </div>
                <h4>费用合计</h4>
                <div class="form-horizontal">
                    <div class="form-group">
                        <label class="col-sm-2 control-label">全保费：</label>
                        <div class="col-sm-10">
                            <p class="form-control-static">${orderInfo.allPremium}</p>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">保险公司跟单手续费：</label>
                        <div class="col-sm-10">
                            <p class="form-control-static">${companyRecord.followRpoundage}</p>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">保险公司补单手续费：</label>
                        <div class="col-sm-10">
                            <p class="form-control-static">${channelRecord.replenishRpoundage}</p>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">税后保费：</label>
                        <div class="col-sm-10">
                            <p class="form-control-static">${orderInfo.texPremium}</p>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">渠道参考返点：</label>
                        <div class="col-sm-10">
                            <p class="form-control-static">${orderInfo.channelLookRebate}</p>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">渠道返点：</label>
                        <div class="col-sm-10">
                            <p class="form-control-static">${orderInfo.channelRebate}</p>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">渠道返佣费合计：</label>
                        <div class="col-sm-10">
                            <p class="form-control-static">${channelRecord.mustRebateAmt}</p>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">渠道应支付保费合计：</label>
                        <div class="col-sm-10">
                            <p class="form-control-static">${channelRecord.mustPremium}</p>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">付款主体：</label>
                        <div class="col-sm-10">
                            <c:choose>
                                <c:when test="${orderInfo.paySubject ==1 }">
                                    <p class="form-control-static">环宇康泰</p>
                                </c:when>
                                <c:when test="${orderInfo.paySubject ==2 }">
                                    <p class="form-control-static">青岛盛达</p>
                                </c:when>
                                <c:when test="${orderInfo.paySubject ==3 }">
                                    <p class="form-control-static">玉环天云</p>
                                </c:when>
                                <c:when test="${orderInfo.paySubject ==4 }">
                                    <p class="form-control-static">汉龙</p>
                                </c:when>
                            </c:choose>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
        <div class="panel-body panel-form">
            <form class="form-horizontal" enctype="multipart/form-data" data-parsley-validate="true"
                  name="demo-form" id="payOrderForm" style="margin-left: 15px;">
                <c:if test="${orderInfo.typeInsurance2!=3}">
                    <div class="form-group">
                        <label class="control-label col-sm-2">收渠道金额：</label>
                        <div class=" col-md-4">
                            <div class="input-group">
                                <input class="form-control" id="receiptChannel" name="receiptChannel" value="${channelRecord.mustPremium}"
                                       data-parsley-required="true" data-parsley-required-message="渠道金额必填"
                                       data-parsley-money="true" data-parsley-money-message="数字格式不正确"/>
                                <div class="input-group-addon">元</div>
                            </div>

                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label col-sm-2">收款日期：</label>
                        <div class="col-md-4">
                            <input class="form-control selectData" name="receiptDate" data-parsley-required="true" value="<fmt:formatDate value="${now}" pattern="yyyy-MM-dd"/>"
                                   data-parsley-required-message="收款日期必填"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label col-sm-2">收款凭证：</label>
                        <div class="col-md-4">
                            <input class="form-control-static" type="file"
                                   data-parsley-max-file-size="10240"
                                   data-parsley-max-file-size-message="文件大小最大是10M"
                                   data-parsley-file-type=".doc,.pdf,.jpg,.png"
                                   data-parsley-file-type-message="文件格式不正确"
                                   id="receiptFile" name="receiptFile"/>
                        </div>
                    </div>
                </c:if>
                <div class="form-group">
                    <label class="control-label col-sm-2">付保险公司金额：</label>
                    <div class="col-md-4">
                        <div class="input-group">
                            <input class="form-control" id="payInsurer" name="payInsurer"
                                   data-parsley-required="true" data-parsley-required-message="保险公司金额必填"
                                   data-parsley-money="true" data-parsley-money-message="数字格式不正确"/>
                            <div class="input-group-addon">元</div>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label col-sm-2" for="payDate">付款日期：</label>
                    <div class="col-md-4">
                        <input class="form-control selectData" type="text" id="payDate" name="payDate" value="<fmt:formatDate value="${now}" pattern="yyyy-MM-dd"/>"
                               data-parsley-required="true" data-parsley-required-message="付款日期必填"/>
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label col-sm-2"
                           for="remark">备注：</label>
                    <div class="col-md-4">
                <textarea class="form-control" id="remark" name="remark"
                          rows="4" data-parsley-maxlength="100" data-parsley-maxlength-message="备注的最大长度是100"
                          placeholder=""></textarea>
                    </div>
                </div>
                <input type="text" name="tid" hidden id="orderId" value="${orderInfo.tid}"/>
                <input type="text" id="payStatus" hidden name="payStatus" value="1"/>
                <div class="form-group">
                    <label class="control-label col-sm-2" for="payDate">&nbsp;</label>
                    <div class="col-md-4">
                        <button type="button" class="btn btn-primary m-r-10" onclick="passInsurer()">支付</button>
                        <button type="button" class="btn  btn-default">取消</button>
                    </div>
                </div>
            </form>
        </div>
</section>
<table class="bg-warning">
    <thead>
    <tr>
        <th>操作记录</th>
        <th>操作人</th>
        <th>操作时间</th>
        <th>备注</th>
    </tr>
    </thead>
    <tbody>
    <c:forEach items="${optionList}" var="opt">
        <tr>
            <td>${opt.content}</td>
            <td>${opt.createUser.roleName}(${opt.createUser.realName})</td>
            <td><javatime:format value="${opt.createAt}" pattern="yyyy-MM-dd HH:mm:ss"/></td>
            <td>${opt.remark}</td>
        </tr>
    </c:forEach>
    </tbody>
</table>
<div class="modal fade" id="modal-dialogs_one">
    <div class="modal-dialog modal-sm">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                <h4 class="modal-title">温馨提示</h4>
            </div>
            <div class="modal-body" id="me1">
            </div>
            <div class="modal-footer">
                <a href="javascript:;" id="payFail" class="btn btn-sm btn-white hidden" onclick="continueOperate(1)">支付失败</a>
                <a href="javascript:;" id="continuePay" class="btn btn-sm btn-success hidden"onclick="continueOperate(2)">继续支付</a>
                <a href="javascript:;" id="cancel" class="btn btn-sm btn-white hidden" data-dismiss="modal">取消</a>
                <a href="javascript:;" id="confirm" class="btn btn-sm btn-success hidden" data-dismiss="modal">确定</a>
            </div>
        </div>
    </div>
</div>
<div class="modal fade" id="modal-dialogs_twe">
    <div class="modal-dialog modal-sm">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                <h4 class="modal-title">温馨提示</h4>
            </div>
            <div class="modal-body" id="me2">
            </div>
            <div class="modal-footer">
                <a href="javascript:;" class="btn btn-sm btn-white" data-dismiss="modal" >取消</a>
                <a href="javascript:;" class="btn btn-sm btn-success" data-dismiss="modal"  onclick="passInsurer()">确定</a>
            </div>
        </div>
    </div>
</div>
<!-- end page container -->
<jsp:include page="../common/footer.jsp"/>
<script type="text/javascript">
    $(document).ready(function () {
        App.init();
        TableManageFixedHeader.init();
        $(".selectData").datepicker({
            autoclose: true, //自动关闭
            beforeShowDay: $.noop, //在显示日期之前调用的函数
            calendarWeeks: false, //是否显示今年是第几周
            clearBtn: false, //显示清除按钮
            daysOfWeekDisabled: [], //星期几不可选
            endDate: Infinity, //日历结束日期
            forceParse: true, //是否强制转换不符合格式的字符串
            format: 'yyyy-mm-dd', //日期格式
            keyboardNavigation: true, //是否显示箭头导航
            language: "zh-CN", //语言
            minViewMode: 0,
            orientation: "auto", //方向
            rtl: false,
            startDate: -Infinity, //日历开始日期
            startView: 0, //开始显示
            todayBtn: false, //今天按钮
            todayHighlight: true, //今天高亮
            weekStart: 0 //星期几是开始
        });
    });
    function passInsurer() {
        $('#payOrderForm').parsley().whenValidate({}).done(function () {
            $("#payOrderForm").ajaxSubmit({
                url: "/ins/order/payOperate",
                type: "POST",
                success: function (data) {
                    console.log(data);
                    if (data.success) {
                        var msgStr;
                        if (data.result == null) {
                            msgStr = "产品信息不存在";
                        } else if (data.result == "success") {
                            window.parent.location.href = "/ins/order/skipOrderList";
                        } else {
                            msgStr = "产品信息已失效，失效日期是" + data.result.product_update_date;
                            if (data.result.status == 1) {
                                $("payStatus").val(3);
                            } else {
                                $("payStatus").val(4);
                            }
                            $("#payFail").removeClass("hidden");
                            $("#continuePay").removeClass("hidden");
                            $("#cancel").addClass("hidden");
                            $("#confirm").addClass("hidden");
                            $("#me1").html(msgStr);
                            $("#modal-dialogs_one").modal("show");
                        }
                    } else {
                        $("#payFail").addClass("hidden");
                        $("#continuePay").addClass("hidden");
                        $("#cancel").removeClass("hidden");
                        $("#confirm").removeClass("hidden");
                        $("#me1").html(data.msg);
                        $("#modal-dialogs_one").modal("show");
                    }
                }
            });
        })
    }
    function continueOperate(payStatus) {
        if (payStatus == 2) {
            $("payStatus").val(payStatus);
        }
        passInsurer();
    }
    window.onload=function(){
        var s = parent.document.getElementById('iframeParent');
        var $tabPane=$('.tab-pane');

        function setIframeHeight(){
            s.style.height =document.body.offsetHeight+'px';
        }

        setIframeHeight();

        $(".nav").find("li").click(function (){
            var $index=$(this).index();
            $tabPane.eq($index).addClass('aa')
            setTimeout(function (){
                if($tabPane.eq($index).hasClass('active')){
                    setIframeHeight();
                }
            },200);
        });
    }
</script>
<!-- ================== END PAGE LEVEL JS ================== -->
</body>
</html>
